<%--
  Created by IntelliJ IDEA.
  User: 31921
  Date: 2024/12/15
  Time: 21:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html; charset=UTF-8" language="java"
pageEncoding="UTF-8" %>
<%@ page import="java.util.*, com.Student, com.Grade" %>
<html>
    <head>
        <title>成绩管理</title>
        <style>
            body {
                font-family: Arial, sans-serif;
                background-color: #f4f4f4;
                margin: 0;
                padding: 0;
            }
            .header {
                background-color: #4cafa7;
                color: white;
                padding: 15px;
                text-align: center;
            }
            .container {
                padding: 20px;
            }
            table {
                width: 100%;
                border-collapse: collapse;
                margin-top: 20px;
            }
            table, th, td {
                border: 1px solid #ddd;
            }
            th, td {
                padding: 10px;
                text-align: left;
            }
            th {
                background-color: #f2f2f2;
            }
            .button {
                background-color: #afaa4c;
                color: white;
                padding: 10px 15px;
                text-decoration: none;
                margin-top: 10px;
                border-radius: 4px;
            }
            .button:hover {
                background-color: #a06045;
            }
        </style>
    </head>
    <body>


        <div class="header">
            <h1>成绩管理系统</h1>
        </div>


        <div class="container">

            <!-- 返回首页按钮 -->
            <a href="home.jsp" class="button">返回首页</a>

            <!-- 新增成绩按钮 -->
            <a href="addGrade.jsp" class="button">新增成绩</a>

            <!-- 成绩列表 -->
            <table>
                <thead>
                <tr>
                    <th>学号</th>
                    <th>姓名</th>
                    <th>课程</th>
                    <th>成绩</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <%
                    List<Grade> grades = (List<Grade>) request.getAttribute("grades");
                    if (grades != null) {
                        for (Grade grade : grades) {
                %>
                <tr>
                    <td><%= grade.getStudentId() %></td>
                    <%--<td>
                        <%
                            // 获取学生姓名，通过 Grade 对象的 getStudentName() 方法
                            String studentName = grade.getStudentName();
                            out.print(studentName);
                        %>
                    </td>--%>
                    <td><%= grade.getStudentName() %></td>
                    <td><%= grade.getCourseName() %></td>
                    <td><%= grade.getGrade() %></td>
                    <td>
                        <a href="gradeManagement?action=edit&id=<%= grade.getId() %>" class="button">编辑</a>
                        <a href="gradeManagement?action=delete&id=<%= grade.getId() %>" class="button">删除</a>
                    </td>
                </tr>
                <%
                        }
                    }
                %>
                </tbody>
            </table>

        </div>

    </body>
</html>

